package com.cardgame.model.archival;

import com.cardgame.model.deck.Deck;
import lombok.Getter;
import lombok.Setter;

import java.util.*;

@Setter
@Getter
public class Archival implements IArchival {
    private Integer money;
    private Map<Integer, Integer> cards; // key: cardId, value: count
    private List<Deck> decks;
    private List<Integer> roles;
    private Integer progress;

    public Archival() {
        this.money = 1000;
        this.cards = new HashMap<>();
        this.decks = new ArrayList<>();
        this.roles = new ArrayList<>();
        this.progress = 1;
    }

    public void addCard(Integer cardId) {
        cards.put(cardId, cards.getOrDefault(cardId, 0) + 1);
    }

    public void addRole(Integer roleId) {
        if (!roles.contains(roleId)) {
            roles.add(roleId);
        }
    }

    public Integer costMoney(Integer amount) {
        if (money >= amount) {
            money -= amount;
            return money;
        }
        return -1;
    }
}
